layui.use('layer', function(){
    var layer = layui.layer;


    let oButton = document.querySelector('.button input')
    let oPassword = document.querySelector('.password input')
    let oPhone = document.querySelector('.phone_p1 input')
    oButton.addEventListener("click",async()=>{
        let res = await axios({
            url:'http://localhost:8080/user/regist',
            method: 'post',
            data: {  // 这样写， 请求中的数据被放入的post请求体中，并且格式为json
              password: oPassword.value,
              username: oPhone.value
            },
            params:{
               abc: 123,
               def: 456
            }
        })
        console.log(res);
        if(res.data.code == -2){
                layer.alert("用户名不能为空")
        }else if(res.data.code == -1){
            layer.alert("密码不能为空")
        }else if(res.data.code == 1){
            layer.msg("注册成功，正在跳转登录页...")
            setTimeout(()=>{
                location.href = `login.html`
            },1500)
        }else{
            layer.alert("该手机号已注册")
        }
    })






    
  });